home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / TCL1 / CDICTION / CPATTERN.C < prev    next >
Text File  |  1989-09-15  |  2KB  |  71 lines

  1. /*****************************************************************************
  2. CDictionary.c
  3.  
  4.     see header for more information.
  5.  
  6. SUPERCLASS = CPane
  7. *****************************************************************************/
  8.  
  9. #include "CPattern.h"
  10. #include "TaoUtils.h"
  11. #include "TBUtilities.h"
  12. #include "OSChecks.h"
  13. /*****************************************************************************/
  14. void CPattern::IPattern(CView *anEnclosure, CBureaucrat *aSupervisor,
  15.                     Int16 aWidth, Int16 aHeight, Int16 aHEncl, Int16 aVEncl,
  16.                     SizingOption aHSizing, SizingOption aVSizing,
  17.                     Int16 resID, Int16 preferColor)
  18. {
  19.     Handle    patH, copy;
  20.     
  21.     CPane::IPane( anEnclosure, aSupervisor, aWidth, aHeight,
  22.                     aHEncl, aVEncl, aHSizing, aVSizing);
  23.                     
  24.     /* get the monochrome pattern */
  25.     
  26.     patH = GetResource( 'PAT ', resID);
  27.     if (patH)
  28.     {
  29.         BlockMove( *patH, itsPattern, sizeof( Pattern));
  30.         ReleaseResource( patH);
  31.     }
  32.     else BlockMove( gray, itsPattern, sizeof( Pattern));
  33.     
  34.     itsPixPat = NIL;
  35.     
  36.     if (preferColor && ColorQDIsPresent())    /* see of a pixpat is available */
  37.     {
  38.         /* IM V says GetPixPat returns NIL if the
  39.             resource doesn't exist */
  40.     
  41.         itsPixPat = GetPixPat( resID);
  42.     }
  43.  
  44.  
  45. }    /* CPattern::IPattern */
  46. /*****************************************************************************/
  47. virtual void CPattern::Draw( Rect *area)
  48. {
  49.     /* if itsPixPat is not nil then we already know ColorQD exists */
  50.     
  51.     if ((itsPixPat)&&IsDeepPort())
  52.         FillCRect( area, itsPixPat);
  53.     else
  54.     {
  55.         HLock( this);
  56.         FillRect( area, itsPattern);
  57.         HUnlock( this);            
  58.     }
  59.     
  60. }    /* CPattern::Draw */
  61. /*****************************************************************************/
  62. void CPattern::Dispose( void)
  63. {
  64.     if (itsPixPat)
  65.         DisposPixPat( itsPixPat);
  66.         
  67.     inherited::Dispose();
  68.  
  69. }    /* CPattern::Dispose */
  70. /*****************************************************************************/
  71.